cmake_minimum_required(VERSION 3.0 FATAL_ERROR)

project(logger)

aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} P7_SOURCES)

add_library(${PROJECT_NAME} SHARED ${P7_SOURCES})

if(WIN32)
    set(P7_PLATFORM_LIBS Ws2_32)
elseif(UNIX)
    set(P7_PLATFORM_LIBS rt pthread)
else()
    message(FATAL_ERROR "${PROJECT_NAME}: Platform not supported")
endif()
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../include/)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../shared/)

target_link_libraries(${PROJECT_NAME} PUBLIC ${P7_PLATFORM_LIBS})

set_property(TARGET ${PROJECT_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)

target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../include/")


if(WIN32)
    target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../shared/Platforms/Windows_x86/")
elseif(UNIX)
    target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../shared/Platforms/Linux_x86/")
endif()

install(TARGETS ${PROJECT_NAME}
        ARCHIVE DESTINATION lib
        LIBRARY DESTINATION lib
        RUNTIME DESTINATION bin)

